$def with (doc, lists)

<div id="contentHead">
    $ header = render_template("lists/header", doc, lists)
    $var title: $_('%(owner)s / Lists', owner=header.title)
    $:header
</div>

$if doc.key.startswith("/subjects/"):
    $ seed = doc.get_seed()
$else:
    $ seed = {"key": doc.key}


$if "type" in doc and doc.type.key == "/type/user":
    <style type="text/css">
        span.list-owner { display: none; }
    </style>
    $if ctx.user and ctx.user.key == doc.key:
        <script type="text/javascript">
            window.q.push(function() {
                \$("#listResults .resultTitle")
                    .prepend('' +
                        '<span class="listDelete sansserif small">' +
                            '<a href="javascript:;"><span></span>$_("Delete this list")</a>' +
                        '</span>')
                    .find(".listDelete a")
                    .click(function() {
                        \$('#delete-dialog')
                            .ol_confirm_dialog(function(){},
                            {
                                buttons: {
                                    "$:_('Yes, I\'m sure')": function() {
                                        var list_id = "#" + \$(this).data("list-id");
                                        var key = \$(list_id + " a:first").attr("href");
                                        var dialog = this;

                                        \$.post(key + "/delete.json", function() {
                                            \$(list_id).remove();
                                            \$(dialog).dialog("close");
                                        });
                                    },
                                    "$_('No, cancel')": function() {
                                        \$(this).dialog("close");
                                    }
                                },
                                closeText: "$_('Close')"
                            })
                            .data("list-id", \$(this).closest("li").attr("id"))
                            .dialog('open');
                        return false;
                    });
            });
        </script>
        <div id="delete-dialog" class="hidden" title="$_('Delete list')">$_('Are you sure you want to delete this list?')</div>
$else:
    <script type="text/javascript">
        window.q.push(function() {
            \$("#listResults .resultTitle.my-list")
            .prepend('' +
                '<span class="listDelete sansserif smaller">' +
                    '<a href="javascript:;"><span></span>$_("Remove this seed?")</a>' +
                '</span>')
            .find(".listDelete a")
            .click(function() {
                \$('#remove-dialog')
                    .ol_confirm_dialog(function() {
                        var seed = $:json_encode(seed);
                        var list_id = "#" + \$(this).data("list-id");
                        var key = \$(list_id + " a:first").attr("href");

                        var dialog = this;

                        remove_seed(key, seed, function() {
                            \$(list_id).remove();
                            \$(dialog).dialog("×");
                        });
                    })
                    .data("list-id", \$(this).closest("li").attr("id"))
                    .dialog('open');
                return false;
            });
        });

        function remove_seed(list_key, seed, success) {
            \$.ajax({
                type: "POST",
                url: list_key + "/seeds.json",
                contentType: "application/json",
                data: JSON.stringify({
                    "remove": [seed]
                }),
                dataType: "json",

                beforeSend: function(xhr) {
                    xhr.setRequestHeader("Content-Type", "application/json");
                    xhr.setRequestHeader("Accept", "application/json");
                },
                success: success
            });
        }
    </script>
    <div id="remove-dialog" class="hidden" title="Remove">$:_('Are you sure you want to remove <strong>%(title)s</strong> from this list?', title=header.title)</div>

<div id="contentBody">
    $if lists:
        <div class="mybooks-list">
            <ul class="list-results" id="listResults">
            $for list in lists:
                <li class="searchResultItem"
                    id="list-$loop.index">$:render_template("lists/preview", list)</li>
            </ul>
        </div>
    $else:
        <p>$_('No lists yet!')</p>
    <div class="clearfix"></div>

    <h2>$_('Recent Activity')</h2>
    $:render_template("lists/activity", doc)
</div>
